﻿using System;

namespace Apodidae.Domain.Entity
{
    public abstract class BaseObject<TId>
    {
        /// <summary>
        /// ID, 主键
        /// </summary>
        public virtual TId Id { get; set; }
        /// <summary>
        /// 是否已删除
        /// </summary>
        public virtual bool IsDeleted { get; set; }
        /// <summary>
        /// 是否已挂起
        /// </summary>
        public virtual bool IsSuspend { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public virtual string Remark { get; set; }
        /// <summary>
        /// 描述
        /// </summary>
        public virtual string Description { get; set; }
        /// <summary>
        /// 名称
        /// </summary>
        public virtual string Name { get; set; }

        private DateTime _createdDate;
        /// <summary>
        /// 创建时间
        /// </summary>
        public virtual DateTime CreatedDate
        {
            get
            {
                if (_createdDate == null || _createdDate == DateTime.MinValue)
                {
                    _createdDate = DateTime.Now;
                    return this._createdDate;
                }
                else
                    return this._createdDate;
            }
            set
            {
                this._createdDate = value;
            }
        }

        private DateTime _lastModified;
        /// <summary>
        /// 最后一次修改时间
        /// </summary>
        public virtual DateTime LastModified
        {
            get
            {
                if (_lastModified == null || _lastModified == DateTime.MinValue)
                {
                    _lastModified = DateTime.Now;
                    return this._lastModified;
                }
                else
                    return this._lastModified;
            }
            set
            {
                this._lastModified = value;
            }
        }
    }
}
